home *** CD-ROM | disk | FTP | other *** search
/ 100 Plus Great Games 2 / 100PLUSV2.BIN / games / WakeRace.dxr / Internal_6_Pickup Manager.ls < prev    next >
Encoding:
Text File  |  2002-01-25  |  4.1 KB  |  128 lines

  1. global gPlayer, gpPickupList, gpCollisionList, gpFeedbackSprite
  2.  
  3. on pickup_Init collisionList
  4.   gpCollisionList = collisionList.duplicate()
  5.   gpPickupList = []
  6.   gpFeedbackSprite = 416
  7.   repeat with n = 300 to 350
  8.     sprite(n).puppet = 0
  9.   end repeat
  10.   sprite(gpFeedbackSprite).puppet = 0
  11. end
  12.  
  13. on pickup_ClearAllPickups
  14.   repeat with n = 300 to 350
  15.     sprite(n).puppet = 0
  16.   end repeat
  17.   sprite(gpFeedbackSprite).puppet = 0
  18. end
  19.  
  20. on pickup_Add theType, theLoc, regenTime, visFX
  21.   if voidp(visFX) then
  22.     visFX = pickup_getVisFX(theType)
  23.   end if
  24.   theSpriteNum = pickup_findASprite(300, 350)
  25.   if theSpriteNum <> 0 then
  26.     sprite(theSpriteNum).puppet = 1
  27.     sprite(theSpriteNum).ink = 36
  28.     sprite(theSpriteNum).member = member(pickup_getMemberName(theType))
  29.     sprite(theSpriteNum).width = sprite(theSpriteNum).member.width
  30.     sprite(theSpriteNum).height = sprite(theSpriteNum).member.height
  31.     add(gpPickupList, [theType, theSpriteNum, theLoc, regenTime, 1, 0, visFX, 2])
  32.   end if
  33. end
  34.  
  35. on pickup_Update theOffset
  36.   repeat with n = 1 to count(gpPickupList)
  37.     if gpPickupList[n][5] then
  38.       sprite(gpPickupList[n][2]).loc = gpPickupList[n][3] - theOffset
  39.       pickup_updateVisFX(n)
  40.       pickup_collisionCheck(n)
  41.       next repeat
  42.     end if
  43.     if the ticks > gpPickupList[n][6] then
  44.       sprite(gpPickupList[n][2]).blend = 100
  45.       sprite(gpPickupList[n][2]).loc = gpPickupList[n][3] - theOffset
  46.       gpPickupList[n][5] = 1
  47.     end if
  48.   end repeat
  49.   if sprite(gpFeedbackSprite).puppet then
  50.     if sprite(gpFeedbackSprite).playing = 0 then
  51.       sprite(gpFeedbackSprite).puppet = 0
  52.     end if
  53.   end if
  54. end
  55.  
  56. on pickup_findASprite minRange, maxRange
  57.   theSpriteNum = 0
  58.   repeat with n = minRange to maxRange
  59.     if sprite(n).puppet = 0 then
  60.       theSpriteNum = n
  61.       exit repeat
  62.     end if
  63.   end repeat
  64.   return theSpriteNum
  65. end
  66.  
  67. on pickup_getMemberName pickupType
  68.   case pickupType of
  69.     #nitro:
  70.       return "Nitro"
  71.   end case
  72. end
  73.  
  74. on pickup_collisionCheck thePickupNum
  75.   repeat with n = 1 to count(gpCollisionList)
  76.     if sprite gpPickupList[thePickupNum][2] intersects sprite(gpCollisionList[n]) then
  77.       gpPickupList[thePickupNum][5] = 0
  78.       gpPickupList[thePickupNum][6] = the ticks + gpPickupList[thePickupNum][4]
  79.       sprite(gpPickupList[thePickupNum][2]).blend = 0
  80.       if gpCollisionList[n] = gPlayer.pMySpriteNum then
  81.         gPlayer.pickupObject(gpPickupList[thePickupNum][1])
  82.         sprite(gpFeedbackSprite).puppet = 1
  83.         sprite(gpFeedbackSprite).member = member("flNitro")
  84.         sprite(gpFeedbackSprite).ink = 36
  85.         sprite(gpFeedbackSprite).loc = point(300, 275)
  86.         updateStage()
  87.       end if
  88.     end if
  89.   end repeat
  90. end
  91.  
  92. on pickup_getVisFX pickupType
  93.   case pickupType of
  94.     #nitro:
  95.       return #pulsate
  96.   end case
  97. end
  98.  
  99. on pickup_updateVisFX thePickupNum
  100.   if ilk(gpPickupList[thePickupNum][7], #list) then
  101.     repeat with n = 1 to count(gpPickupList[thePickupNum][7])
  102.       pickup_updateEffect(thePickupNum, gpPickupList[thePickupNum][7][n])
  103.     end repeat
  104.   else
  105.     pickup_updateEffect(thePickupNum, gpPickupList[thePickupNum][7])
  106.   end if
  107. end
  108.  
  109. on pickup_updateEffect thePickupNum, visFXType
  110.   case visFXType of
  111.     #rotate:
  112.       sprite(gpPickupList[thePickupNum][2]).rotation = sprite(gpPickupList[thePickupNum][2]).rotation + 5
  113.       if sprite(gpPickupList[thePickupNum][2]).rotation > 360 then
  114.         sprite(gpPickupList[thePickupNum][2]).rotation = sprite(gpPickupList[thePickupNum][2]).rotation - 360
  115.       end if
  116.     #pulsate:
  117.       sprite(gpPickupList[thePickupNum][2]).width = sprite(gpPickupList[thePickupNum][2]).width + gpPickupList[thePickupNum][8]
  118.       sprite(gpPickupList[thePickupNum][2]).height = sprite(gpPickupList[thePickupNum][2]).height + gpPickupList[thePickupNum][8]
  119.       if sprite(gpPickupList[thePickupNum][2]).width > (sprite(gpPickupList[thePickupNum][2]).member.width + 10) then
  120.         gpPickupList[thePickupNum][8] = gpPickupList[thePickupNum][8] * -1
  121.       else
  122.         if sprite(gpPickupList[thePickupNum][2]).width < (sprite(gpPickupList[thePickupNum][2]).member.width - 10) then
  123.           gpPickupList[thePickupNum][8] = gpPickupList[thePickupNum][8] * -1
  124.         end if
  125.       end if
  126.   end case
  127. end
  128.